<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<title>The Gimme Javascript Library :: Skeleton Test Page</title>

		<script type = "text/javascript" src = "../jsunit/app/jsUnitCore.js"></script>
		<script type = "text/javascript" src = "../utils/jsunit/jsUnitHelperFunctions.js"></script>
		<script type = "text/javascript" src = "../build/debug/gimme.js"></script>
		
		<script type = "text/javascript">
			var pageHTML;
			function setUpPage()
			{
				pageHTML = document.body.innerHTML;
				setUpPageStatus = 'complete';
			}
			function setUp()
			{
				document.body.innerHTML = pageHTML;				
			}
		
			function test_get_firstNameTypeAttribute()
			{
				var val = Gimme('#firstName').get_attr('type');
				assertEquals('Attribute value is not "text"', 'text', val);
			}
			
			function test_get_aboutRowsAttribute()
			{
				// note: most browsers return attributes as string, but IE returns numeric value attributes as numbers,
				// so we need to explicitely use .toString() to get the comparison to assert true			
				var val = Gimme('#about').get_attr('rows');
				assertEquals('Attribute value is not 5', '5', val.toString());
			}
			
			function test_get_aboutColsAttribute()
			{
				// note: most browsers return attributes as string, but IE returns numeric value attributes as numbers,
				// so we need to explicitely use .toString() to get the comparison to assert true			
				var val = Gimme('#about').get_attr('cols');
				assertEquals('Attribute value is not 30', '30', val.toString());
			}	

			function test_get_label1ForAttribute()
			{
				var val = Gimme('#label1').get_attr('for');
				assertEquals('Attribute value is not "firstName"', 'firstName', val);
			}
			
			function test_get_firstNameMaxlengthAttribute()
			{
				// note: most browsers return attributes as string, but IE returns numeric value attributes as numbers,
				// so we need to explicitely use .toString() to get the comparison to assert true			
				var val = Gimme('#firstName').get_attr('maxlength');
				assertEquals('Attribute value is not 50', '50', val.toString());
			}
			
			// This test fails in IE inside of the test environment because, well, it's IE.  It should succeed is non-test environments though
			function test_get_link1HrefAttribute()
			{
				var val = Gimme('#link1').get_attr('href');
				assertEquals('Attribute value is not #someAnchor', '#someAnchor', val);
			}
			
			function test_setLabel1ForAttribute()
			{
				var label = this.get('label1');
				Gimme(label).set_attr('for', 'steve');
				assertEquals('for attribute was not successfully set to "steve"', label.getAttribute('for', 2), 'steve');
			}
			
			function test_setArbitraryFooAttributeOnAllElements()
			{
				var gObj = Gimme('*');
				gObj.set_attr('foo', 'bar');
				gObj.iterate(function(i)
				{
					assertEquals('foo attribute was not successfully set to "bar"', gObj.get_attr('foo'), 'bar');
				});
			}
		
		</script>
	</head>

	<body>
		<h1>Gimme Attribute Tests</h1>

		<div id = "container" class = "personal">
			<label id = "label1" for = "firstName" class = "warning">
			<input id = "firstName" name = "firstName" type = "text" size = "50" maxlength = "50" />
			<textarea id = "about" rows = "5" cols = "30">Tell us about yourself.</textarea>
			<a id = "link1" href = "#someAnchor">Jump to anchor</a>
		</div>
	</body>

</html>